package com.jingtai.shop.service.goods.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jingtai.common.enums.DeleteFlagEnum;
import com.jingtai.core.entity.shop.ShufflingFigure;
import com.jingtai.core.mapper.shop.ShufflingFigureMapper;
import com.jingtai.shop.service.goods.ShufflingFigureService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 轮播图表 服务实现类
 * </p>
 *
 * @author GR123
 * @since 2020-11-29
 */
@Service
public class ShufflingFigureServiceImpl extends ServiceImpl<ShufflingFigureMapper, ShufflingFigure> implements ShufflingFigureService {

    @Resource
    private ShufflingFigureService figureService;

    /**
     * 首页查询轮播图列表
     */
    @Override
    public List<ShufflingFigure> listShufflingFigure() {
        List<ShufflingFigure> figureList = figureService.list(Wrappers.lambdaQuery(ShufflingFigure.class)
                .orderByDesc(ShufflingFigure::getWeight)
                .eq(ShufflingFigure::getDeleteFlag, DeleteFlagEnum.NOT_DELETE.getCode()));
        return CollectionUtil.isNotEmpty(figureList) ? figureList : new ArrayList<>();
    }
}
